<template>
  <div class="productList">
    <nav-top title="我的收藏" :goback="true" :remove="true" @remove="remove"></nav-top>
    <header>
      <van-field
        class="search"
        v-model="filed"
        clearable
        right-icon="search"
        placeholder="搜索收藏产品名称"
        @click-right-icon="$toast('question')"
      />
    </header>
    <section class="partTwo" v-if="showList">
      <ul v-if="!operation">
        <li class="list" v-for="(val,key) in productList" :key="key">
          <div class="img">
            <img :src="val.imgUrl" alt />
          </div>
          <div class="msg">
            <p class="name">{{val.name}}</p>
            <span class="intro">{{val.intro}}</span>
            <span class="price">¥{{val.price}}</span>
          </div>
        </li>
      </ul>
      <van-checkbox-group v-model="result" v-else>
        <van-checkbox
          class="list"
          checked-color="#06a44f"
          v-for="(val, key) in productList"
          :key="key"
          :name="val"
        >
          <img
              class="check-icon"
            slot="icon"
            slot-scope="props"
            :src="props.checked ? '/static/icon/select-select.png' : '/static/icon/select-none.png'"
          />
          <div class="content">
            <div class="img">
              <img :src="val.imgUrl" alt />
            </div>
            <div class="msg">
              <p class="name">{{val.name}}</p>
              <span class="intro">{{val.intro}}</span>
              <span class="price">¥{{val.price}}</span>
            </div>
          </div>
        </van-checkbox>
      </van-checkbox-group>
    </section>
    <div v-if="operation && showList" class="footer">
      <button @click="operation = false" class="cancel">取消</button>
      <button class="remove">删除(<span v-html="selectCount"/>)</button>
    </div>
    <section class="without" v-if="!showList">
      <img src="/static/img/collection/withoutCollection.png" alt />
    </section>
  </div>
</template>

<script>
import NavTop from "@/components/nav/navBar";
export default {
  name: "ProductList",
  components: {
    NavTop
  },

  data() {
    return {
      filed: "",
      productList: [
        {
          imgUrl: "/static/img/product-img.png",
          name: "产品名称显示产品名称显示产品",
          price: "9999",
          intro:
            "产品概述展示产品概述展示产品概述展示产品盖上展示产品概述展示概述展示"
        },
        {
          imgUrl: "/static/img/product-img.png",
          name: "产品名称显示产品名称显示产品",
          price: "9999",
          intro:
            "产品概述展示产品概述展示产品概述展示产品盖上展示产品概述展示概述展示产品盖上展示产品概述展示概述展示产品盖上展示产品概述展示概述展示"
        },
        {
          imgUrl: "/static/img/product-img.png",
          name: "产品名称显示产品名称显示产品",
          price: "9999",
          intro:
            "产品概述展示产品概述展示产品概述展示产品盖上展示产品概述展示概述展示"
        }
      ],
      result: [],
      operation: false,
      showList: false,
      selectCount: 0
    };
  },
  mounted() {
    if (this.productList.length > 0) {
      this.showList = true;
    }
  },
  methods: {
    remove() {
      this.operation = true;
    }
  }
};
</script>

<style lang='scss' scoped>
.productList {
  padding-bottom: 60px;
  .search {
    margin-top: 50px;
    height: 30px;
    padding: 0 23px;
    border-bottom: 1px solid #E6E6E6;
    input {
      line-height: 40px;
      :-ms-input-placeholder {
        font-size: 12px;
        font-family: Microsoft YaHei;
        font-weight: 400;
        color: rgba(194, 194, 194, 1);
      }
    }
  }
  
  .search::after {
    border: none;
  }

  .list {
    display: flex;
    margin: 11px auto;
    width: 300px;
    height: 110px;
    border: 1px solid #f8f8f8;
    border-radius: 5px;
    // box-shadow: 2px 2px 10px #909090;
    .check-icon{
      width: 15px;
      height: 15px;
    }
    .content {
      display: flex !important;
    }
    .img {
      width: 83px !important;
      height: 83px !important;
      margin: 13px 0 17px 10px !important;
      img {
        width: 83px;
        height: 83px;
      }
    }
    .msg {
      margin: 17px 0 0 8px;
      .name {
        padding-right: 25px;
        margin: 0;
        font-size: 15px;
        font-family: Microsoft YaHei;
        font-weight: bold;
        color: rgba(0, 0, 0, 1);
        display: -webkit-box;
        /*! autoprefixer: off */
        -webkit-box-orient: vertical;
        /*! autoprefixer: on */
        -webkit-line-clamp: 1;
        overflow: hidden;
      }
      .intro {
        margin-top: 8px;
        padding-right: 25px;
        font-size: 11px;
        display: -webkit-box;
        /*! autoprefixer: off */
        -webkit-box-orient: vertical;
        /*! autoprefixer: on */
        -webkit-line-clamp: 2;
        overflow: hidden;
      }
      .price {
        display: block;
        margin-top: 6px;
        font-size: 13px;
        font-weight: bold;
        color: rgba(27, 162, 83, 1);
      }
      span {
        font-size: 11px;
        font-family: Microsoft YaHei;
        font-weight: 400;
        color: rgba(102, 102, 102, 1);
      }
    }
  }
  .footer {
    margin-bottom: 0;
    width: 320px;
    height: 35px;
    display: flex;
    background: #fff;

    .cancel {
      width: 160px;
      font-size: 12px;
      font-family: Microsoft YaHei;
      font-weight: 400;
      color: rgba(51, 51, 51, 1);
      background: #fff;
      border: 1px solid #f8f8f8;
    }
    .remove {
      border: 1px solid #f8f8f8;
      width: 160px;
      font-size: 12px;
      font-family: Microsoft YaHei;
      font-weight: 400;
      color: rgba(6, 164, 79, 1);
      background: #fff;
    }
  }
  .without {
    text-align: center;
    img {
      margin-top: 222px;
      width: 61px;
      height: 80px;
    }
  }
}
</style>
<style>
.productList .list .van-checkbox__icon {
  margin: 51px 0 0 14px;
  width: 15px;
  height: 15px;
}
.productList .list .van-checkbox__icon i {
  width: 15px;
  height: 15px;
}
.productList .list .van-checkbox__label {
  margin: 0;
}
</style>